<?php

class Article extends Item {
	
	const TYPE_ARTICLE = 0;
	const TYPE_STORY = 1;
	
	public function getUrl() {
		$pageAlias = '';
		if ($this['article_type'] == self::TYPE_STORY) {
			$pageRepository = new PageRepository();
			$page = $pageRepository->getOneByUid($this['pid']);
			if ($page) {
				$pageAlias = $page['alias'];
			}
		}
		
		if ($pageAlias == '') {
			$pageAlias = 'novinky';
		}
		
		return $pageAlias . '/' . $this['alias'] . '.html';
	}
	
	public function getPosts() {
		$postRepository = new PostRepository();
		return $postRepository->getByFkArticleId($this['uid']);
	}
}

?>